package com.boge.whitelist.config;


import com.boge.mtbatis.DoJoinPoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Configuration ： 标注为配置文件
 * @ConditionalOnClass： 当WhiteListProperties  CLASS 位于类路径上 ，加载WhiteListProperties
 * @EnableConfigurationProperties ：加载WhiteListProperties类
 */
@Configuration
@ConditionalOnClass(WhiteListProperties.class)
@EnableConfigurationProperties(WhiteListProperties.class)
public class WhiteListAutoConfigure {

    /***
     * ConditionalOnMissingBean ： 全局上下文不存在的时候，才会实例这个Bean
     */
    @Bean("whiteListConfig")
    @ConditionalOnMissingBean
    public String whiteListConfig(WhiteListProperties properties) {
        return properties.getUsers();
    }


    @Bean
    @ConditionalOnMissingBean
    public DoJoinPoint point(){
        return new DoJoinPoint();
    }

}

  